package org.td.engine;

import com.badlogic.gdx.InputProcessor;

public class InputHook implements InputProcessor {

    private InputProcessor inputProcessor;

    private int dragAmountX;
    private int dragAmountY;

    private int lastTouchX;
    private int lastTouchY;

    public InputHook(InputProcessor inputProcessor) {
        this.inputProcessor = inputProcessor;
    }

    public int getDragAmountX() {
        return dragAmountX;
    }

    public int getDragAmountY() {
        return dragAmountY;
    }

    @Override
    public boolean keyDown(int keycode) {
        return inputProcessor.keyDown(keycode);
    }

    @Override
    public boolean keyUp(int keycode) {
        return inputProcessor.keyUp(keycode);
    }

    @Override
    public boolean keyTyped(char character) {
        return inputProcessor.keyTyped(character);
    }

    @Override
    public boolean touchDown(int screenX, int screenY, int pointer, int button) {
        lastTouchX = screenX;
        lastTouchY = screenY;
        return inputProcessor.touchDown(screenX, screenY, pointer, button);
    }

    @Override
    public boolean touchUp(int screenX, int screenY, int pointer, int button) {
        return inputProcessor.touchUp(screenX, screenY, pointer, button);
    }

    @Override
    public boolean touchDragged(int screenX, int screenY, int pointer) {
        dragAmountX = screenX - lastTouchX;
        dragAmountY = screenY - lastTouchY;
        lastTouchX = screenX;
        lastTouchY = screenY;
        return inputProcessor.touchDragged(screenX, screenY, pointer);
    }

    @Override
    public boolean mouseMoved(int i, int i1) {
        return inputProcessor.mouseMoved(i, i1);
    }

    @Override
    public boolean scrolled(int amount) {
        return inputProcessor.scrolled(amount);
    }
}
